package com.life.ai.server.modules.develop.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.life.ai.server.common.domain.PageQuery;
import com.life.ai.server.common.domain.R;
import com.life.ai.server.modules.develop.entity.SysJob;
import com.life.ai.server.modules.develop.service.SysJobService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 基础表结构 前端控制器
 *
 * @author kyle
 * @since  2025-01-06
 */
@Api(tags = "基础表结构-接口列表")
@RestController
@RequestMapping("/sysJob")
public class SysJobController {

    @Resource
    private SysJobService sysJobService;

                        
    /**
    * 基础表结构-单条查询
    */
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "单条查询")
    @GetMapping("/{id}")
    public R<SysJob> queryOne(@PathVariable("id")Long id){
        return R.ok(sysJobService.getById(id));
    }

    /**
     * 基础表结构-分页查询
     */
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "分页查询")
    @GetMapping("/page")
    public R<Page<SysJob>> queryPage(PageQuery pageQuery,SysJob sysJob){
        Page<SysJob> page = sysJobService.queryPage(pageQuery,sysJob);
        return R.ok(page);
    }

    /**
     * 基础表结构-新增
     */
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "新增")
    @PostMapping("/add")
    public R<Void> save(@RequestBody SysJob sysJob){
        sysJobService.save(sysJob);
        return R.ok();
    }

    /**
     * 基础表结构-修改
     */
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "修改")
    @PutMapping("/update")
    public R<Void> update(@RequestBody SysJob sysJob){
        sysJobService.updateById(sysJob);
        return R.ok();
    }

    /**
     * 基础表结构-删除
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "删除")
    @DeleteMapping("/delete/{id}")
    public R<Void> delete(@PathVariable("id")Long id){
        sysJobService.removeById(id);
        return R.ok();
    }

    /**
     * 基础表结构-批量删除
     */
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "批量删除")
    @PostMapping("/deleteBatch")
    public R<Void> deleteBatch(@RequestBody List<Long> list){
        sysJobService.removeByIds(list);
        return R.ok();
    }
}